package com.itheima_2;

import java.lang.reflect.Field;

public class RFilectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException {
        //meothd();
        //meothd1();


    }

    public static void meothd1() throws ClassNotFoundException, NoSuchFieldException, InstantiationException, IllegalAccessException {
        Class aClass = Class.forName("com.itheima_2.Student");
        Field field = aClass.getDeclaredField("money");
        field.setAccessible(true);
        Student o = (Student) aClass.newInstance();
        Object o1 = field.get(o);
        System.out.println(o1);
    }

    public static void meothd() throws ClassNotFoundException, NoSuchFieldException, InstantiationException, IllegalAccessException {
        Class aClass = Class.forName("com.itheima_2.Student");
        Field name = aClass.getField("name");
        Student o =(Student) aClass.newInstance();
        name.set(o,"zhansan");
        System.out.println(o);
    }
}
